// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using SnapObjects.Commons;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Specifies that the database will generate a default value for the mapped column.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class SqlDefaultValueAttribute : Attribute, ISqlDefaultValue
    {
        /// <summary>
        ///     Initializes a new instance of the SqlDefaultValueAttribute class.
        /// </summary>
        /// <param name="defaultValue">
        ///     The definition of the column default value in the database. 
        ///     This parameter is only used to show the definition.
        /// </param>
        public SqlDefaultValueAttribute(string defaultValue)
        {
            Check.NotEmpty(defaultValue, nameof(defaultValue));
            this.DefaultValue = defaultValue;
        }

        /// <summary>
        ///     Gets the definition of the default value for the mapped column in database.
        /// </summary>
        public string DefaultValue { get; }
    }
}
